package com.example.yingjiguanli_demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.yingjiguanli_demo.pojo.Posts;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author scj
 * @since 2024-11-04
 */
@Mapper
public interface PostsMapper extends BaseMapper<Posts> {
    /**
     * 分页查询推文
     * @param offset 查询的起始位置
     * @param pageSize 每页大小
     * @return 推文列表
     */
    @Select("SELECT * FROM posts LIMIT #{offset}, #{pageSize}")
    List<Posts> getPostsByPage(@Param("offset") int offset, @Param("pageSize") int pageSize);

    /**
     * 查询推文总数量
     * @return 推文总数
     */
    @Select("SELECT COUNT(*) FROM posts")
    int getTotalPostsCount();
}
